package com.scienview.web.service;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import com.scienview.web.dao.BaseDao;

public class BaseService<T> {

	private Class<T> clazz;
	
	@SuppressWarnings("unchecked")
	public BaseService(){
		Type type=this.getClass().getGenericSuperclass();
		if(type instanceof ParameterizedType){
			ParameterizedType parameterizedType=(ParameterizedType)type;
			Type[] t=parameterizedType.getActualTypeArguments();
			if(t.length>0&&t[0] instanceof Class){
				this.clazz=(Class<T>)t[0];
			}
		}
	}
	public void insert(T t){
		
	}
	public T get(String id){
		return baseDao.get(clazz, id);
	}
	BaseDao<T> baseDao;
}
